#ifndef SYSTEMVIEW_H_
#define SYSTEMVIEW_H_

#include "LunTotalStatistics.h"
#include "ExtentEntry.h"
#include "DeviceData.h"
#include "SystemAllocation.h"
#include "TimeCorrelation.h"
#include <vector>

using namespace std;

/*
debug=0 --> no debugging
*/
#define DEBUG 2

typedef struct Cache
{
	int cache_size;    // total cache size in bytes
	int nof_partitions;   // number of partitions
	int* partition_sizes;  // array of all partition sizes
	int** partition_luns;  // array of all luns in each partition. Example: [[1,2],[3,4],[5]]
}
Cache;

class SystemView {
	 int time_slice_size; // size of each time slice (3600 right now)
	 int nof_time_slices;
	 map<LUNID, LunTotalStatistics*>* my_luns;
	 set<DeviceData*>* allDevices;
	 Cache* my_cache;
	 SystemAllocation* allocation;
	 set<ExtentEntry*>* my_entries;
	 map<LUNID, map<__int64, Extent*>*>* allExtents;
	 TimeCorrelation* time_correlation;
	 int exchange_limit;

public:
	SystemView ();	/*constructor*/
	~SystemView(void); /*destructor*/


	void writeAllocStats();
	DeviceData* getDevice(string type);
	void addEntry (ExtentEntry* e);
	int getTimeSliceSize();
	int getNof_time_slices() { return nof_time_slices; };
	void setNof_time_slices(int a) { nof_time_slices=a; };
	set<DeviceData*>* getAllDevices();
	set<ExtentEntry*>* getMy_entries();
	map<LUNID, LunTotalStatistics*>* getMy_luns();
	void increaseTimeSlices();
	void addLun (pair<const LUNID,LunTotalStatistics*> l);
	LunTotalStatistics* getLunTotalStatistics(const LUNID id);
	void updateLuns(LUNID id,ExtentEntry* entry);
	void addDevice(DeviceData* d);
	void setMyCache(Cache* c){ my_cache = c; };
	Cache* getCache(){ return my_cache; };
	void divide_all_lun_priorities(int i);  /* i=1 for p=1/response_time, i=0 for p=1 */
	SystemAllocation* getAllocation() { return allocation; };
	void divide_system(double ssdnum, double fcnum, double satanum);
	Extent* getExtent(LUNID id, __int64 offset);
	map<int, double>* getTimeCorrOutput();
	void startTimeCorrelation(int time);
	void stopTimeCorrelation(int time);
	int calculate_time_correlation(int time, list<ExtentStatsAlgo*>* SSD);
	void startOver();
	void setLimit(int c) {exchange_limit = c;};
	int getLimit() {return exchange_limit;};
};
#endif /* SYSTEMVIEW_H */